using System;
using System.Configuration;

namespace ECCIT.Data
{
	public class ConnectionInfo
	{
		public static string GetConnectionString()
		{
			string sReturnValue = ConfigurationSettings.AppSettings["CONNECTIONSTRING"].ToString();
			return sReturnValue;
		}

		public static DataBaseType GetDataBaseType()
		{
			string sDbType = ConfigurationSettings.AppSettings["DATABASETYPE"].ToString();
			DataBaseType dbtReturn = (DataBaseType)Enum.Parse(typeof(DataBaseType), sDbType);
			return dbtReturn;
		}

        public static int GetCommandTimeout()
        {
            int timeout = 30;
            if (ConfigurationSettings.AppSettings["COMMANDTIMEOUT"] != null)
                timeout = int.Parse(ConfigurationSettings.AppSettings["COMMANDTIMEOUT"].ToString());

            return timeout;
        }

        public static BaseDBHelper GetDBHelper()
        {
            DataBaseType dbType = GetDataBaseType();
            BaseDBHelper dbHelper = null;
            switch (dbType)
            {
                case DataBaseType.SQLServer:
                    dbHelper = new SqlHelper();
                    break;
                case DataBaseType.Oracle:
                    dbHelper = new OracleHelper();
                    break;
                case DataBaseType.OleDb:
                    dbHelper = new OleDbHelper();
                    break;
            }

            return dbHelper;
        }
	}
}
